/**
  ******************************************************************************
  * File Name          : route_dk_tonet.c
  * Description        : Code for freertos applications
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include <string.h>
#include "tskcfg.h"
#include "route.h"
#include "ctrl_common.h"

#if (ROUTE_INTEGRATED > 0)
void Route_dj_tonet_ptstate(void)
{
	Route_dk_st_Type *dkst = NULL;
  Route_PayloadType *proute = NULL;
  
  proute = pvPortMalloc(sizeof(Route_PayloadType));
  if(proute != NULL)
  {
    memset(proute, 0, sizeof(Route_PayloadType));
	
    dkst = (Route_dk_st_Type *)proute->payload;
    proute->length = sizeof(Route_dk_st_Type);
    
    strncpy(dkst->did, Route_DeviceList.dk[0].did, ROUTE_DID_BUFLEN);
    dkst->root   = ROUTE_ROOT_SUBDEV_TO_NET;
    dkst->device = RT_DV_DK;
    dkst->subtyp = ROUTE_SUBTYP_DK_UP_STATE;
    dkst->dkst   = Ctrl_StateDK;
    
    if(Route_EvewToNet_Qhd != NULL)
    {
      xQueueSend(Route_EvewToNet_Qhd, proute, 0);
    }
  }
  
  vPortFree(proute);
}

void Route_dj_tonet_ptpara(void)
{
	Route_dk_para_Type *dk = NULL;
  Route_PayloadType *proute = NULL;
  
  proute = pvPortMalloc(sizeof(Route_PayloadType));
  if(proute != NULL)
  {
    memset(proute, 0, sizeof(Route_PayloadType));
	
    dk = (Route_dk_para_Type *)proute->payload;
    proute->length = sizeof(Route_dk_para_Type);
    
    strncpy(dk->did, Route_DeviceList.dk[0].did, ROUTE_DID_BUFLEN);
    dk->root   = ROUTE_ROOT_SUBDEV_TO_NET;
    dk->device = RT_DV_DK;
    dk->subtyp = ROUTE_SUBTYP_DK_UP_PARA;
    dk->dk     = Ctrl_ParaDK;
    
    if(Route_EvewToNet_Qhd != NULL)
    {
      xQueueSend(Route_EvewToNet_Qhd, proute, 0);
    }
  }
  
  vPortFree(proute);
}
#endif
